package priv.yan;

import java.util.Scanner;

public class ChickenAndRabbit {
    public static void main(String[] args) {
        while(true){

       Scanner input=new Scanner(System.in);
        System.out.println("请输入总的头数:");
        int num=input.nextInt();
        System.out.println("请输入总脚数:");
        int foot=input.nextInt();


        for (int ra=0,ch=num; ra<=num;ra++,ch--){
            if (ra*4+ch*2==foot) {
                System.out.println("若有鸡兔共" + num + "只,共" + foot + "只脚,那么有" + ch + "只鸡,有" + ra + "只兔子");
                }
            }
        System.out.println("如果想退出则输入1,想继续执行则输入2");
        int flag=input.nextInt();
        if (flag==1) break;
        }
    }
}
